package kozt;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.content.*;
import android.net.*;

import arceneaux.com.kozt.R;

public class KOZTPlayer extends Activity
{
	private static final String TAG = "KOZTPlayer";

	// private static final String URL = "rtsp://koztlinux.kozt.com/kozt.sdp";
	private static final String KALW_URL = "http://www.kalw.org/media/Streaming%20Links/kalw-mp3.pls";
	private static final String KFOG_URL = "http://www.kfog.com/ListenLive.aspx";
	private static final String URL = "http://koztlinux.kozt.com:3000/kozt.m3u";

	/** Called when the activity is first created. */
	@Override
	public void onCreate (Bundle savedInstanceState)
	{
		super.onCreate (savedInstanceState);

		Log.d (TAG, "App started");

		setContentView (R.layout.main);
		
/*
		TextView npTitle = new TextView (this);
		npTitle.setTextColor (0xe3fd26);
		// npTitle.set
		npTitle.setText ("Now Playing");
		setContentView (npTitle);
*/
		
		Uri uri = Uri.parse (URL);
		Log.d (TAG, "URI to " + uri.getHost ());

		MediaPlayer player = new MediaPlayer ();
		if (player != null)
		{
			Log.d (TAG, "Player created.");

			try
			{
				player.reset ();
				Log.d (TAG, "Loading: " + KALW_URL);
				player.setDataSource (KALW_URL);
				player.setAudioStreamType (AudioManager.STREAM_MUSIC);
				player.prepare ();
				player.start ();
			} 
			catch (Exception e)
			{
				Log.d (TAG, "Exception: " + e.getLocalizedMessage ());
			}
		} 
		else
			Log.d (TAG, "Player not created.");
	}
}